package intf

import (
	C "gitee.com/ljfirst/algo-go-sdk/common/constant"
	"gitee.com/ljfirst/algo-go-sdk/src/data_structure/array/xor"
	"gitee.com/ljfirst/algo-go-sdk/src/data_structure/heap_stack_queue/heap"
	"gitee.com/ljfirst/algo-go-sdk/src/data_structure/sort/inner_sort"
)

// 所有排序算法的接口
type ArraySortINTF interface {
	SortMethod(array []int)
	GetAttribute() *C.Attribute
}

/* 返回数组中最小的 k 个元素 -> 堆排法和快排法
Returns the smallest k elements in this array */
type ReturnKMinINTF interface {
	ReturnKMin([]int, int) []int
	GetAttribute() *C.Attribute
}

// 超过半数的数
type OverHalfNumINTF interface {
	Method([]int) int
	GetAttribute() *C.Attribute
}

type FindNum interface {
	FindMethod([]int32) []int32
	GetAttribute() *C.Attribute
}

var ArraySortINTFAssemble = map[string][]interface{}{
	"Sort": {
		&inner_sort.BubbleSort{},
		&inner_sort.InsertSort{},
		&inner_sort.SelectSort{},
		&inner_sort.MergeSort{},

		&inner_sort.QuickSortSimplex{},
		&inner_sort.QuickSortDuplex{},
		&inner_sort.QuickSortNonRecursive{},
		//&QuickSortByInsertOptimize{},

		inner_sort.NewHeapSort(),
		inner_sort.NewHeapSort2(),
		/*&CountSort{},
		&BucketSort{},
		&RadixSort{},
		&ShellSort{},*/
	},
	"ReturnKMin": {
		&heap.ReturnKMinByQuickSort{},
		&heap.ReturnKMinByHeapSort{},
	},
	"Xor": {
		&xor.FindNum_Twice_One{},  // 找出数组中唯一出现一次的数(其他数出现2次)
		&xor.FindNum_Twice_Two{},  // 找出数组中唯二出现一次的数(其他数出现2次)
		&xor.FindNum_Treble_One{}, // 找出数组中唯一出现一次的数(其他数出现3次)
	},
}
